package com.yll.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yll.dao.UserDao;
import com.yll.domain.Student;
import com.yll.domain.User;
import com.yll.service.UserService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public User findByUsernameAndPassword(String username, String password) {
        return userDao.findByUsernameAndPassword(username,password);
    }

    @Override
    public void add(Student student) {
        userDao.add(student);
    }

    @Override
    public PageInfo<Student> pageQuery(Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<Student> list = userDao.findAll();
        System.out.println("list = " + list);
        PageInfo<Student> info = new PageInfo<>(list);
        return info;
    }

    @Override
    public Student findById(Integer id) {
        return userDao.findById(id);
    }
}
